<template>
  <div class="app-container">
    <el-card style="margin-bottom: 10px">
      <h2 style="margin: 0">课程列表</h2>
    </el-card>
    <el-card>
      <el-table v-loading="loading" :data="courseList">
        <el-table-column label="课程名称" align="center" prop="courseName" />
        <el-table-column label="学分" width="50" align="center" prop="credit" />
        <el-table-column label="所属专业" align="center" prop="profession" />
        <el-table-column label="课程人数" align="center" prop="courseNumber" />
        <el-table-column label="学期" align="center" prop="semester" />
        <el-table-column label="教师" align="center" prop="teacherName" />
        <el-table-column label="课程类别" align="center" prop="courseType">
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.ocss_course_type"
              :value="scope.row.courseType"
            />
          </template>
        </el-table-column>

        <el-table-column label="上课时段" align="center" prop="classTimer" />
        <el-table-column label="上课地点" align="center" prop="classLocation" />
        <el-table-column label="成绩" align="center" prop="achievement">
          <template v-slot="scope">
            <el-tag v-if="scope.row.achievement > 59" type="success">
              {{ scope.row.achievement }}
            </el-tag>
            <el-tag v-else type="danger">
              {{ scope.row.achievement }}
            </el-tag>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import { studentCourseList } from "@/api/system/achievement";

export default {
  name: "Course",
  dicts: ["ocss_course_type", "ocss_course_status"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],

      // 总条数
      total: 0,
      // 课程信息表格数据
      courseList: [],

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询课程信息列表 */
    getList() {
      this.loading = true;
      studentCourseList(this.queryParams).then((response) => {
        this.courseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
  },
};
</script>
